Skip to content

[css-text-4] Add an optional second value to hyphenate-character to render the unchosen ­ #12255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jfrech opened this issue May 31, 2025 · 0 comments

Comments

@jfrech
Copy link

jfrech commented May 31, 2025

Status quo

Currently, hyphenate-character's values are defined as (cf. https://www.w3.org/TR/css-text-4/#hyphenate-character [2025-05-31])

hyphenate-character = auto | <string>

with the semantics that when a &shy; word-break opportunity is taken, the &shy; character is rendered as the given string (which has an auto default). When a &shy; word-break opportunity isn't taken, the &shy; character isn't rendered.

Proposal

I propose adding a second, optional argument to hyphenate-character with default value "" that specifies the rendering of a &shy; character whose word-break opportunity isn't taken:

hyphenate-character = auto | <string> | <string> <string>

The rendered, untaken &shy; becomes part of the physical text with regards to selection ranges.

Motivation

Hyphenation rules in modern English (e.g. en-GB) and German after the spelling reform (e.g. de-DE) fit hyphenate-character's model well: when you can break, break and add a hyphen, else don't break and leave the word alone.

However, when typesetting German preceding the spelling reform (language code de-DE-1901), hyphenation may add and remove letters:

((de-DE-1901))

Nach Tagen der Suche konnte sie eine Pampelmuse entdecken, und begann, ein Stilleben anzufertigen.
                                                     ^^ "ck" -> "k-k"         ^^ "ll" -> "ll-l"
    
Nach Tagen der Suche konnte
sie eine Pampelmuse entdek-
ken, und begann, ein Still-
leben anzufertigen.

Adding letters "ll" -> "ll-l" when breaking can be achieved with contemporary CSS:

<p lang="de-DE-1901">Nach Tagen der Suche konnte sie eine Pampelmuse entdecken, und begann, ein
<span style="hyphenate-character: 'l-';">Stil&shy;le</span>&shy;ben
anzufertigen.</p>

But changing letters "ck" -> "k-k" when breaking, to my knowledge, cannot be achieved in pure CSS (I have written an ECMAScript resize observer which changes letters' display: none styling, though it possibly falls into a never-ending loop when the font rendering gives different characters too dissimilar widths).
With an unused-&shy; text parameter to hyphenate-character, the break opportunity could be aptly described:

<p lang="de-DE-1901">Nach Tagen der Suche konnte sie eine Pampelmuse
ent&shy;<span style="hyphenate-character: 'k-' 'c';">de&shy;ken</span>,
und begann, ein Stilleben anzufertigen.</p>

Raison d'être

I think adding an as-described non-taken &shy; rendering argument to hyphenate-character opens up the possibility for correctly breaking justified de-DE-1901 text, a feature CSS is currently lacking, through a generic feature without introducing de-DE-1901-specific styling rules.

Pre-orthography-reform German has its place on the Web: when citing older texts in a justified layout, incorrectly breaking invalidates the citation and not breaking aesthetically hurts the text. Furthermore, active publications exist that choose to write in de-DE-1901 (e.g. Lettre International (cf. https://www.lettre.de/ [2025-05-31]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants